package cn.kgc.tangcco.http;

import cn.hutool.core.date.DateUtil;
import cn.kgc.tangcco.utils.localdatetime.BaseLocalDateTimeUtil;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * @author 李昊哲
 * @Description
 * @create 2020/10/13 下午2:02
 */
@WebServlet(urlPatterns = "/networkInfo")
public class NetworkInfo extends HttpServlet {
    private static final long serialVersionUID = 3395472552582105386L;

    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        // 客户端(远程机器) http://192.168.34.237:8080/day02/networkInfo
//        System.out.println("客户IP地址：" + request.getRemoteAddr());
//        System.out.println("客户IP地址：" + request.getRemoteHost());
//        System.out.println("客户端口号：" + request.getRemotePort());

        // 服务器端（本地机器）
//        System.out.println("服务器IP地址：" + request.getLocalAddr());
//
//        System.out.println("服务器端口：" + request.getLocalPort());
//        System.out.println("请求的URL：" + request.getRequestURL());
        System.out.println(DateUtil.now() + "\t客户端:"  + request.getRemoteAddr() + ":" + request.getRemotePort() + "\t请求的URL：" + request.getRequestURL());
        System.out.println("----------------------------------------------------");
    }
}
